package com.jx.lcs.datareport.service;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jx.lcs.datareport.dao.DataReportDao;
import com.jx.lcs.datareport.entity.DataReport;
import com.jx.lcs.product.dao.ProductDao;
import com.jx.lcs.product.entity.ProductInfo;
import com.tianyu.jty.common.persistence.HibernateDao;
import com.tianyu.jty.common.service.BaseService;
import com.tianyu.jty.common.utils.DateUtils;
import com.jx.lcs.util.export.SheetDefination;
import com.jx.lcs.util.export.Excel4MapExporter;
import com.jx.lcs.util.export.ExcelExporter;

/**
 * 数据报表Service
 * 
 * @author JiaYY
 * @date 2015年7月3日
 */

@Service
@Transactional(readOnly = true)
public class DataReportService extends BaseService<DataReport, String> {

	private static final String OS_IOS = "ios";
	private static final String OS_ANDROID = "android";
	private static final String OS_ALL = "全部";

	@Autowired
	private DataReportDao dataReportDao;

	@Autowired
	private ProductDao productDao;

	@Override
	public HibernateDao<DataReport, String> getEntityDao() {
		return dataReportDao;
	}

	/**
	 * 获取用户相关数据报表信息
	 * 
	 * @param date
	 */
	public List<Map<String, Object>> findUserDataReport(String beginDate,
			String endDate) {
		
		if (StringUtils.isBlank(beginDate)) {
			beginDate = DateUtils.getDate();
		}
		if (StringUtils.isBlank(endDate)) {
			endDate = DateUtils.getDate();
		}
		endDate = DateUtils.addDays(endDate, 1);
		
		System.out.println("--查询日期：" + beginDate + " - " + endDate);

		List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();

		// 累计注册用户
		int totalRegistUserNum = dataReportDao.findTotalRegistUserNum(
				null, null);
		// 累计登录用户
		int totalLoginUserNum = dataReportDao.findTotalLoginUserNum(null,
				null, null);
		// 累计登录用户-ios
		int totalLoginUserNumOfIOS = dataReportDao.findTotalLoginUserNum(
				null, null, OS_IOS);
		// 累计登录用户-android
		int totalLoginUserNumOfAndroid = dataReportDao.findTotalLoginUserNum(
				null, null, OS_ANDROID);

		// 注册用户数
		int registUserNum = dataReportDao.findRegistUserNum(beginDate, endDate);

		// 登录次数
		int loginTimesNum = dataReportDao.findLoginTimesNum(beginDate, endDate,
				null);
		// 累计登录次数-ios
		int loginTimesNumOfIOS = dataReportDao.findLoginTimesNum(beginDate,
				endDate, OS_IOS);
		// 累计登录次数-android
		int loginTimesNumOfAndroid = dataReportDao.findLoginTimesNum(beginDate,
				endDate, OS_ANDROID);

		// 登录用户数
		int loginUserNum = dataReportDao.findLoginUserNum(beginDate, endDate,
				null);
		// 累计登录用户数-ios
		int loginUserNumOfIOS = dataReportDao.findLoginUserNum(beginDate,
				endDate, OS_IOS);
		// 累计登录用户数-android
		int loginUserNumOfAndroid = dataReportDao.findLoginUserNum(beginDate,
				endDate, OS_ANDROID);

		// 新增用户数
		int newUserNum = dataReportDao.findNewUserNum(beginDate, endDate, null);
		// 累计新增用户数-ios
		int newUserNumOfIOS = dataReportDao.findNewUserNum(beginDate, endDate, OS_IOS);
		// 累计新增用户数-android
		int newUserNumOfAndroid = dataReportDao.findNewUserNum(beginDate, endDate, OS_ANDROID);

		System.out.println("累计注册用户数：" + totalRegistUserNum);
		System.out.println("累计登录用户数：" + totalLoginUserNum);
		System.out.println("累计登录用户数-iOS：" + totalLoginUserNumOfIOS);
		System.out.println("累计登录用户数-安卓：" + totalLoginUserNumOfAndroid);
		System.out.println("注册用户数：" + registUserNum);
		System.out.println("登录次数：" + loginTimesNum);
		System.out.println("登录次数-iOS：" + loginTimesNumOfIOS);
		System.out.println("登录次数-安卓：" + loginTimesNumOfAndroid);
		System.out.println("登录用户数：" + loginUserNum);
		System.out.println("登录用户数-iOS：" + loginUserNumOfIOS);
		System.out.println("登录用户数-安卓：" + loginUserNumOfAndroid);
		System.out.println("新增用户数：" + newUserNum);
		System.out.println("新增用户数-iOS：" + newUserNumOfIOS);
		System.out.println("新增用户数-安卓：" + newUserNumOfAndroid);

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("os", OS_IOS);
		map.put("totalRegistUserNum", "");
		map.put("totalLoginUserNum", totalLoginUserNumOfIOS);
		map.put("registUserNum", "");
		map.put("loginTimesNum", loginTimesNumOfIOS);
		map.put("loginUserNum", loginUserNumOfIOS);
		map.put("newUserNum", newUserNumOfIOS);
		dataList.add(map);

		map = new HashMap<String, Object>();
		map.put("os", OS_ANDROID);
		map.put("totalRegistUserNum", "");
		map.put("totalLoginUserNum", totalLoginUserNumOfAndroid);
		map.put("registUserNum", "");
		map.put("loginTimesNum", loginTimesNumOfAndroid);
		map.put("loginUserNum", loginUserNumOfAndroid);
		map.put("newUserNum", newUserNumOfAndroid);
		dataList.add(map);

		map = new HashMap<String, Object>();
		map.put("os", "全部");
		map.put("totalRegistUserNum", totalRegistUserNum);
		map.put("totalLoginUserNum", totalLoginUserNum);
		map.put("registUserNum", registUserNum);
		map.put("loginTimesNum", loginTimesNum);
		map.put("loginUserNum", loginUserNum);
		map.put("newUserNum", newUserNum);
		dataList.add(map);

		// map.put("totalLoginUserNum", totalLoginUserNum);
		// map.put("totalLoginUserNumOfIOS", totalLoginUserNumOfIOS);
		// map.put("totalLoginUserNumOfAndroid", totalLoginUserNumOfAndroid);
		// map.put("registUserNum", registUserNum);
		// map.put("loginTimesNum", loginTimesNum);
		// map.put("loginTimesNumOfIOS", loginTimesNumOfIOS);
		// map.put("loginTimesNumOfAndroid", loginTimesNumOfAndroid);
		// map.put("loginUserNum", loginUserNum);
		// map.put("loginUserNumOfIOS", loginUserNumOfIOS);
		// map.put("loginUserNumOfAndroid", loginUserNumOfAndroid);
		// map.put("newUserNum", newUserNum);
		// map.put("newUserNumOfIOS", newUserNumOfIOS);
		// map.put("newUserNumOfAndroid", newUserNumOfAndroid);

		return dataList;
	}

	/**
	 * 获取产品相关数据报表信息
	 * 
	 * @param date
	 */
	public List<Map<String, Object>> findProductDataReport(String beginDate,
			String endDate, HttpServletRequest request) {
		
		boolean isAll = false;
		
		if (StringUtils.isBlank(beginDate)) {
			beginDate = "2015-01-01";
		}
		if (StringUtils.isBlank(endDate)) {
			isAll = true;
			endDate = DateUtils.getDate();
		}
		endDate = DateUtils.addDays(endDate, 1);
		
		String iosChecked = request.getParameter("iOS_checked");
		String androidChecked = request.getParameter("Android_checked");
		String allChecked = request.getParameter("all_checked");
		
		List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
		List<ProductInfo> list = productDao.findAll("beginAgentDay", false);
		if (list != null && list.size() > 0) {
			// 产品代理次数-ios
			Map<String, Integer> proAgentTimesOfIOSMap = dataReportDao
					.findProductAgentTimesNum(beginDate, endDate, OS_IOS);
			// 产品代理人数-ios
			Map<String, Integer> proAgentUserOfIOSMap = dataReportDao
					.findProductAgentUserNum(beginDate, endDate, OS_IOS);
			// 产品预约次数-ios
			Map<String, Integer> proOrderTimesOfIOSMap = dataReportDao
					.findProductOrderTimesNum(beginDate, endDate, OS_IOS);
			// 产品预约人数-ios
			Map<String, Integer> proOrderUserOfIOSMap = dataReportDao
					.findProductOrderUserNum(beginDate, endDate, OS_IOS);
			// 产品预约客户数-ios
			Map<String, Integer> proOrderCustomerOfIOSMap = dataReportDao
					.findProductOrderCustomerNum(beginDate, endDate, OS_IOS);
			
			// 产品代理次数-安卓
			Map<String, Integer> proAgentTimesOfAndroidMap = dataReportDao
					.findProductAgentTimesNum(beginDate, endDate, OS_ANDROID);
			// 产品代理人数-安卓
			Map<String, Integer> proAgentUserOfAndroidMap = dataReportDao
					.findProductAgentUserNum(beginDate, endDate, OS_ANDROID);
			// 产品预约次数-安卓
			Map<String, Integer> proOrderTimesOfAndroidMap = dataReportDao
					.findProductOrderTimesNum(beginDate, endDate, OS_ANDROID);
			// 产品预约人数-安卓
			Map<String, Integer> proOrderUserOfAndroidMap = dataReportDao
					.findProductOrderUserNum(beginDate, endDate, OS_ANDROID);
			// 产品预约客户数-安卓
			Map<String, Integer> proOrderCustomerOfAndroidMap = dataReportDao
					.findProductOrderCustomerNum(beginDate, endDate, OS_ANDROID);
			
			// 产品代理人数-all
			Map<String, Integer> proAgentUserOfAllMap = dataReportDao
					.findProductAgentUserNum(beginDate, endDate, null);
			// 产品预约人数-all
			Map<String, Integer> proOrderUserOfAllMap = dataReportDao
					.findProductOrderUserNum(beginDate, endDate, null);
			// 产品预约客户数-all
			Map<String, Integer> proOrderCustomerOfAllMap = dataReportDao
					.findProductOrderCustomerNum(beginDate, endDate, null);
			
			Map<String, Integer> proCurrAgentUserOfIOSMap = null;
			Map<String, Integer> proCurrOrderUserOfIOSMap = null;
			Map<String, Integer> proCurrOrderCustomerOfIOSMap = null;
			Map<String, Integer> proCurrAgentUserOfAndroidMap = null;
			Map<String, Integer> proCurrOrderUserOfAndroidMap = null;
			Map<String, Integer> proCurrOrderCustomerOfAndroidMap = null;
			Map<String, Integer> proCurrAgentUserOfAllMap = null;
			Map<String, Integer> proCurrOrderUserOfAllMap = null;
			Map<String, Integer> proCurrOrderCustomerOfAllMap = null;
			
			if(isAll) {
				// 产品当前代理理财师数-ios
				proCurrAgentUserOfIOSMap = dataReportDao
						.findProductCurrAgentUserNum(OS_IOS);
				// 产品当前预约理财师数-ios
				proCurrOrderUserOfIOSMap = dataReportDao
									.findProductCurrOrderUserNum(OS_IOS);
				// 产品当前预约客户数-ios
				proCurrOrderCustomerOfIOSMap = dataReportDao
									.findProductCurrOrderCustomerNum(OS_IOS);
				
				// 产品当前代理人数-安卓
				proCurrAgentUserOfAndroidMap = dataReportDao
						.findProductCurrAgentUserNum(OS_ANDROID);
				// 产品当前预约理财师数-安卓
				proCurrOrderUserOfAndroidMap = dataReportDao
												.findProductCurrOrderUserNum(OS_ANDROID);
				// 产品当前预约客户数-安卓
				proCurrOrderCustomerOfAndroidMap = dataReportDao
												.findProductCurrOrderCustomerNum(OS_ANDROID);
				
				// 产品当前代理人数-all
				proCurrAgentUserOfAllMap = dataReportDao
						.findProductCurrAgentUserNum(null);
				// 产品当前预约理财师数-all
				proCurrOrderUserOfAllMap = dataReportDao
									.findProductCurrOrderUserNum(null);
				// 产品当前当前预约客户数-all
				proCurrOrderCustomerOfAllMap = dataReportDao
									.findProductCurrOrderCustomerNum(null);
			}
			
			String pname = "";
			String pcode = "";
			
			Map<String, Object> data = null;
			//代理次数-汇总
			int totalProAgentTimes = 0;
			//预约次数-汇总
			int totalProOrderTimes = 0;
			
			for (ProductInfo product : list) {
				//判断产品售卖时间 
				Date queryBeginDate = null;
				if(beginDate != null) {
					queryBeginDate = DateUtils.parseDate(beginDate);
				}
				Date queryEndDate = null;
				if(endDate != null) {
					queryEndDate = DateUtils.parseDate(endDate);
				}
				
				if(queryBeginDate != null && queryEndDate != null) {
					if (product.getBeginAgentDay() != null) {
						if(product.getBeginAgentDay().getTime() > queryEndDate.getTime()
								|| product.getEndPaymentDay().getTime() < queryBeginDate.getTime()) {
							continue;
						}
					}	
				} else if(queryBeginDate != null) {
					if(product.getEndPaymentDay().getTime() < queryBeginDate.getTime()) {
						continue;
					}
				} else if(queryEndDate != null) {
					if(product.getBeginAgentDay().getTime() > queryEndDate.getTime()) {
						continue;
					}
				}
				
				pname = product.getPname();
				pcode = product.getPcode();
				
				System.out.println("--产品：" + pname);
				
				//iOS相关
				int proAgentTimesOfIOS = this.getProductCountNumByPcode(proAgentTimesOfIOSMap, pcode);
				int proAgentUserOfIOS = this.getProductCountNumByPcode(proAgentUserOfIOSMap, pcode);
				int proOrderTimesOfIOS = this.getProductCountNumByPcode(proOrderTimesOfIOSMap, pcode);
				int proOrderUserOfIOS = this.getProductCountNumByPcode(proOrderUserOfIOSMap, pcode);
				int proOrderCustomerOfIOS = this.getProductCountNumByPcode(proOrderCustomerOfIOSMap, pcode);
				int proCurrAgentUserOfIOS = this.getProductCountNumByPcode(proCurrAgentUserOfIOSMap, pcode);
				int proCurrOrderUserOfIOS = this.getProductCountNumByPcode(proCurrOrderUserOfIOSMap, pcode);
				int proCurrOrderCustomerOfIOS = this.getProductCountNumByPcode(proCurrOrderCustomerOfIOSMap, pcode);
				
				//android相关
				int proAgentTimesOfAndroid = this.getProductCountNumByPcode(proAgentTimesOfAndroidMap, pcode);
				int proAgentUserOfAndroid = this.getProductCountNumByPcode(proAgentUserOfAndroidMap, pcode);
				int proOrderTimesOfAndroid = this.getProductCountNumByPcode(proOrderTimesOfAndroidMap, pcode);
				int proOrderUserOfAndroid = this.getProductCountNumByPcode(proOrderUserOfAndroidMap, pcode);
				int proOrderCustomerOfAndroid = this.getProductCountNumByPcode(proOrderCustomerOfAndroidMap, pcode);
				int proCurrAgentUserOfAndroid = this.getProductCountNumByPcode(proCurrAgentUserOfAndroidMap, pcode);
				int proCurrOrderUserOfAndroid = this.getProductCountNumByPcode(proCurrOrderUserOfAndroidMap, pcode);
				int proCurrOrderCustomerOfAndroid = this.getProductCountNumByPcode(proCurrOrderCustomerOfAndroidMap, pcode);
				
				//os全部
				int proAgentTimesOfAll = proAgentTimesOfIOS + proAgentTimesOfAndroid;
				int proAgentUserOfAll = this.getProductCountNumByPcode(proAgentUserOfAllMap, pcode);
				int proOrderTimesOfAll = proOrderTimesOfIOS + proOrderTimesOfAndroid;
				int proOrderUserOfAll = this.getProductCountNumByPcode(proOrderUserOfAllMap, pcode);
				int proOrderCustomerOfAll = this.getProductCountNumByPcode(proOrderCustomerOfAllMap, pcode);
				int proCurrAgentUserOfAll = this.getProductCountNumByPcode(proCurrAgentUserOfAllMap, pcode);
				int proCurrOrderUserOfAll = this.getProductCountNumByPcode(proCurrOrderUserOfAllMap, pcode);
				int proCurrOrderCustomerOfAll = this.getProductCountNumByPcode(proCurrOrderCustomerOfAllMap, pcode);
				
				totalProAgentTimes += proAgentTimesOfAll;
				totalProOrderTimes += proOrderTimesOfAll;
				
				/*
				System.out.println("产品代理次数-iOS：" + proAgentTimesOfIOS);
				System.out.println("产品代理人数-iOS：" + proAgentUserOfIOS);
				System.out.println("产品预约次数-iOS：" + proOrderTimesOfIOS);
				System.out.println("产品预约人数-iOS：" + proOrderUserOfIOS);
				System.out.println("产品预约客户数-iOS：" + proOrderCustomerOfIOS);
				System.out.println("产品当前代理人数-iOS：" + proCurrAgentUserOfIOS);
				
				System.out.println("产品代理次数-安卓：" + proAgentTimesOfAndroid);
				System.out.println("产品代理人数-安卓：" + proAgentUserOfAndroid);
				System.out.println("产品预约次数-安卓：" + proOrderTimesOfAndroid);
				System.out.println("产品预约人数-安卓：" + proOrderUserOfAndroid);
				System.out.println("产品预约客户数-安卓：" + proOrderCustomerOfAndroid);
				System.out.println("产品当前代理人数-安卓：" + proCurrAgentUserOfAndroid);
				
				System.out.println("产品代理次数-全部：" + proAgentTimesOfAll);
				System.out.println("产品代理人数-全部：" + proAgentUserOfAll);
				System.out.println("产品预约次数-全部：" + proOrderTimesOfAll);
				System.out.println("产品预约人数-全部：" + proOrderUserOfAll);
				System.out.println("产品预约客户数-全部：" + proOrderCustomerOfAll);
				System.out.println("产品当前代理人数-全部：" + proCurrAgentUserOfAll);
				*/
				
				//选中ios
				if(iosChecked == null || "true".equals(iosChecked)) {
					data = new HashMap<String, Object>();
					data.put("os", OS_IOS);
					data.put("pname", pname);
					data.put("proAgentTimes", proAgentTimesOfIOS);
					data.put("proAgentUser", proAgentUserOfIOS);
					data.put("proOrderTimes", proOrderTimesOfIOS);
					data.put("proOrderUser", proOrderUserOfIOS);
					data.put("proOrderCustomer", proOrderCustomerOfIOS);
					
					data.put("proCurrAgentUser", proCurrAgentUserOfIOS);
					data.put("proCurrOrderUser", proCurrOrderUserOfIOS);
					data.put("proCurrOrderCustomer", proCurrOrderCustomerOfIOS);
					dataList.add(data);
				}
				
				//选中android
				if(androidChecked == null || "true".equals(androidChecked)) {
					data = new HashMap<String, Object>();
					data.put("os", OS_ANDROID);
					data.put("pname", pname);
					data.put("proAgentTimes", proAgentTimesOfAndroid);
					data.put("proAgentUser", proAgentUserOfAndroid);
					data.put("proOrderTimes", proOrderTimesOfAndroid);
					data.put("proOrderUser", proOrderUserOfAndroid);
					data.put("proOrderCustomer", proOrderCustomerOfAndroid);
					
					data.put("proCurrAgentUser", proCurrAgentUserOfAndroid);
					data.put("proCurrOrderUser", proCurrOrderUserOfAndroid);
					data.put("proCurrOrderCustomer", proCurrOrderCustomerOfAndroid);
					dataList.add(data);
				}
				
				//选中全部
				if(allChecked == null || "true".equals(allChecked)) {
					data = new HashMap<String, Object>();
					data.put("os", OS_ALL);
					data.put("pname", pname);
					data.put("proAgentTimes", proAgentTimesOfAll);
					data.put("proAgentUser", proAgentUserOfAll);
					data.put("proOrderTimes", proOrderTimesOfAll);
					data.put("proOrderUser", proOrderUserOfAll);
					data.put("proOrderCustomer", proOrderCustomerOfAll);
					
					data.put("proCurrAgentUser", proCurrAgentUserOfAll);
					data.put("proCurrOrderUser", proCurrOrderUserOfAll);
					data.put("proCurrOrderCustomer", proCurrOrderCustomerOfAll);
					dataList.add(data);
				}	
			}

			// 代理人数-全部
			int totalProAgentUser = dataReportDao.findProductAgentUserNumAll(
					beginDate, endDate);
			// 预约人数-全部
			int totalProOrderUser = dataReportDao.findProductOrderUserNumAll(
					beginDate, endDate);
			// 预约客户数-全部
			int totalProOrderCustomer = dataReportDao
					.findProductOrderCustomerNumAll(beginDate, endDate);
			
			// 当前代理理财师数-全部
			int totalProCurrAgentUser = 0;
			// 当前预约理财师数-全部
			int totalProCurrOrderUser = 0;
			// 当前预约客户数-全部
			int totalProCurrOrderCustomer = 0;
			
			if(isAll) {
				totalProCurrAgentUser = dataReportDao.findProductCurrAgentUserNumAll();
				totalProCurrOrderUser = dataReportDao.findProductCurrOrderUserNumAll();
				totalProCurrOrderCustomer = dataReportDao.findProductCurrOrderCustomerNumAll();
			}
			
//			System.out.println("代理次数-全部：" + totalProAgentTimes);
//			System.out.println("代理人数-全部：" + totalProAgentUser);
//			System.out.println("预约次数-全部：" + totalProOrderTimes);
//			System.out.println("预约人数-全部：" + totalProOrderUser);
//			System.out.println("预约客户数-全部：" + totalProOrderCustomer);

			data = new HashMap<String, Object>();
			data.put("os", "总计");
			data.put("pname", "");
			data.put("proAgentTimes", totalProAgentTimes);
			data.put("proAgentUser", totalProAgentUser);
			data.put("proOrderTimes", totalProOrderTimes);
			data.put("proOrderUser", totalProOrderUser);
			data.put("proOrderCustomer", totalProOrderCustomer);
			
			data.put("proCurrAgentUser", totalProCurrAgentUser);
			data.put("proCurrOrderUser", totalProCurrOrderUser);
			data.put("proCurrOrderCustomer", totalProCurrOrderCustomer);
			dataList.add(data);
		}
		return dataList;
	}
	
	/**
	 * 获取产品代理预约相关统计数量
	 * @param result
	 * @param pcode
	 * @return
	 */
	public int getProductCountNumByPcode(Map<String, Integer> result, String pcode) {
		int num = 0;
		if(result != null && result.containsKey(pcode)) {
			num = result.get(pcode);
		}
		return num;
	}

	/**
	 * 数据报表导出
	 * 
	 * @param date
	 *            查询日期
	 * @throws IOException
	 */
	public void exportDataReport(String beginDate, String endDate, HttpServletRequest request,
			OutputStream out) throws IOException {

		// 产品相关
		List<Map<String, Object>> productData = this.findProductDataReport(
				beginDate, endDate, request);

		SheetDefination<Map<String, Object>> prodSheetDefination = new SheetDefination<>();
		prodSheetDefination.setSheetTitle("产品相关");
		
		//如果结束日期不为空
		if(!StringUtils.isBlank(endDate)){
			prodSheetDefination.setHeaders(new String[] { "系统", "产品名称", "代理次数",
					"代理理财师数", "预约次数", "预约理财师数", "预约客户数" });
			prodSheetDefination.setDataKeys(new String[] { "os", "pname",
					"proAgentTimes", "proAgentUser", "proOrderTimes",
					"proOrderUser", "proOrderCustomer" });
		} else {
			prodSheetDefination.setHeaders(new String[] { "系统", "产品名称", "代理次数",
					"代理理财师数", "当前代理理财师数", "预约次数", "预约理财师数", "当前预约理财师数", "预约客户数", "当前预约客户数" });
			prodSheetDefination.setDataKeys(new String[] { "os", "pname",
					"proAgentTimes", "proAgentUser", "proCurrAgentUser", "proOrderTimes",
					"proOrderUser", "proCurrOrderUser", "proOrderCustomer", "proCurrOrderCustomer" });
		}
		
		prodSheetDefination.setDataset(productData);

		// 用户相关
		List<Map<String, Object>> userData = this.findUserDataReport(beginDate,
				endDate);

		SheetDefination<Map<String, Object>> userSheetDefination = new SheetDefination<>();
		userSheetDefination.setSheetTitle("用户相关");
		userSheetDefination.setHeaders(new String[] { "系统", "累计注册用户", "累计登录用户",
				"注册数", "登录次数", "登录用户数", "新增登录用户" });
		userSheetDefination.setDataKeys(new String[] { "os",
				"totalRegistUserNum", "totalLoginUserNum", "registUserNum",
				"loginTimesNum", "loginUserNum", "newUserNum" });
		userSheetDefination.setDataset(userData);

		List<SheetDefination<Map<String, Object>>> definations = new ArrayList<>();
		definations.add(prodSheetDefination);
		definations.add(userSheetDefination);

		ExcelExporter<Map<String, Object>> exportExcel = new Excel4MapExporter();
		exportExcel.export(definations, out);
	}
}
